package company.tencent;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-16 11:34
 */
public class T2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            Map<Integer,City> map  = new HashMap<>();
            for (int i = 0; i < m; i++) {
                int u = scanner.nextInt();
                int v = scanner.nextInt();
                if (map.containsKey(u)){
                    City temp = map.get(u);
//                    temp.in = temp.in + 1;
                    temp.out = temp.out + 1;
                    map.put(u,temp);
                }else {
                    City temp = new City();
                    map.put(u,temp);
                }

                if (map.containsKey(v)){
                    City temp = map.get(v);
                    temp.in = temp.in + 1;
//                    temp.out = temp.out + 1;
                    map.put(v,temp);
                }else {
                    City temp = new City();
                    map.put(v,temp);
                }
            }


            int res = 0;

            for (City city : map.values()) {
                if (city.in == city.out)
                    res++;
            }

            System.out.println(res);
        }
    }
}

class City{
    int in  = 0;
    int out = 0;
}

